import com.fourinone.BeanContext;
import com.fourinone.ParkLocal;
import com.fourinone.CacheLocal;

public class CachePutDemo
{
	public static void putSmallCache(String[] keyArray)
	{
		ParkLocal pl = BeanContext.getPark();
		pl.create("cache", "keyArray", keyArray);
	}
	
	public static String[] putBigCache(int index)
	{
		CacheLocal cc = BeanContext.getCache();
		String[] keyArray = new String[10000];
		for(int i=0;i<10000;i++)
			keyArray[i] = cc.add("key"+index, "value"+i);
		return keyArray;
	}
	
	static class Worker implements Runnable {
	    
        private int index;
	    public Worker(int index){
	        this.index = index;
	    }
	    
        @Override
        public void run() {
          
            String[] keyArray = putBigCache(index);
            putSmallCache(keyArray);
        }
	    
	}
	
	public static void main(String[] args){
		for(int i = 0; i < 100;i++){
		    Thread t = new Thread(new Worker(i), "t_" + i);
		    t.start();
		}
	}
}